package server;

/**
 * @author sxnan
 * @className HttpProtocolUtil
 * @description TODO
 * @date 2020/7/21
 */
public class HttpProtocolUtil {

    /**
     * 获取200状态的返回头
     * @param length
     * @return
     */
    public static String getHeaderStr200(long length){
        return "HTTP/1.1 200 OK \n"+
                "Content-Type: text/html;charset=utf-8 \n"+
//                "Content-Length: "+length+" \n"+
                "\r\n"
                ;
    }

    /**
     * 获取404状态的返回头
     * @return
     */
    public static String getHeaderStr404(){
        String str404 = "<h1>404 not found</h1>";
        return "HTTP/1.1 404 NOT Found \n"+
                "Content-Type: text/html;charset=utf-8 \n"+
//                "Content-Length: "+str404.getBytes().length+" \n"+
                "\r\n" +str404;
    }
}
